package com.example.securingadmin;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.HashMap;
import java.util.Map;

/**
 * @author caiwl
 * @date 2020/12/8 16:56
 */
public class SecurityUtils {
    public static Map<String, LoginUser> tokenMap = new HashMap<>();

    public static LoginUser getLoginUser() {
        return (LoginUser) getAuthentication().getPrincipal();
    }

    public static Authentication getAuthentication() {
        return SecurityContextHolder.getContext().getAuthentication();
    }
}
